package com.zhongli.devplatform.controller.sys;

import com.zhongli.devplatform.dto.sys.DictionaryDirectoryDTO;
import com.zhongli.devplatform.query.sys.DictionaryDirectoryQuery;
import com.zhongli.devplatform.service.imp.sys.IDictionaryDirectoryService;
import com.zhongli.devplatform.bean.Res;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dictionaryDirectory")
public class DictionaryDirectoryController {


    @Autowired
    private IDictionaryDirectoryService dictionaryDirectoryService;

    @PostMapping("/listPage")
    public Res listPage(DictionaryDirectoryQuery query) {
        return new Res(dictionaryDirectoryService.listPage(query));
    }

    @RequestMapping("/refreshCache")
    public Res refreshCache() {

        dictionaryDirectoryService.putCache();
        return new Res(null);
    }

    @PostMapping("/save")
    public Res save(DictionaryDirectoryDTO dictionaryDirectoryDTO) {
        dictionaryDirectoryService.save(dictionaryDirectoryDTO);
        return new Res(null);
    }

    @RequestMapping("/delete")
    public Res delete(@RequestBody List<Long> ids) {
        dictionaryDirectoryService.delete(ids);
        return new Res(null);
    }

    @RequestMapping("/isExist")
    public Res isExist(DictionaryDirectoryQuery query) {
        return new Res(dictionaryDirectoryService.isExist(query));
    }


}
